/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Connection.DataAccess;
import Model.ChungLoai;

/**
 *
 * @author My PC
 */
public class ChungLoaiController {
     public static boolean ThemCL(ChungLoai cl)
    {
        try 
        {
            
           String sql = String.format("INSERT INTO tblSanPham (MA_CHUNGLOAI, "
                   + "TEN_CHUNGLOAI, MOTA) "
                   + "values (N'%s',N'%s',N'%s')", cl.getMaChungloai(),
                   cl.getTenChungloai(),cl.getMota());
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
     public static boolean XoaCL(ChungLoai cl)
    {
        try 
        {
            
           String sql = String.format("delete from tblChungLoai where MA_CHUNGLOAI =N'%s'",cl.getMaChungloai());
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
     public static boolean SuaCL(ChungLoai cl)
    {
        try 
        {
            
           String sql = String.format("UPDATE tblChungLoai SET TEN_CHUNGLOAI = N'%s',"
                    + "MOTA = N'%s' WHERE MA_CHUNGLOAI= N'%s'",
                  cl.getTenChungloai(),cl.getMota(),cl.getMaChungloai());
           DataAccess da=new DataAccess();
           da.executeUpdate(sql);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    
}
